#include <iostream>
using namespace std;

class A {
public:
	A(int data):m_data(data) {
		cout << "公共基类子对象:" << this << "," << sizeof (A)<<endl; 
	}
	int m_data;
};

class B:virtual public A{ //虚继承
public:
	B (int data):A(data) {
		cout << "B子对象:" << this << ',' << sizeof (B) << endl;
	}
	void set (int data) {
		m_data = data;
	}
};
class C:virtual public A{
public:
	C (int data):A(data) {
		cout << "C子对象:" << this << ',' << sizeof (C) << endl;
	}
	int get (void) {
		return m_data;
	}
};
class D:public B, public C {
public:
	D(int data):B(data), C(data), A(data){
		cout << "汇聚子类D对象" << this << ',' << sizeof(D) << endl;
	}
};
int main (void)
{
	D d (100);
	cout << d.get() << endl;
	d.set (1000);
	cout << d.get() << endl;

	return 0;
}
